import com.alibaba.druid.pool.DruidDataSourceFactory;
import dao.BrandDao;
import entity.Brand;
import utils.DbUtils;

import javax.sql.DataSource;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import java.util.Properties;

public class DruidUse02 {
    public static void main(String[] args) throws SQLException {
//        查
//        queryBrand();


//        增加
//        Brand brand1 = new Brand();
//        brand1.setDescription("aaaaa");
//        brand1.setBrandName("aaaaa");
//        brand1.setCompanyName("aaaaa");
//        brand1.setOrdered(2);
//        AddBrand(brand1);

//        更新
//        Brand brand2 = new Brand();
//        brand2.setDescription("bbb");
//        brand2.setBrandName("bbb");
//        brand2.setCompanyName("bbb");
//        brand2.setOrdered(4);
//        brand2.setId(4);
//        brand2.setStatus(1);
//        UpdateBrand(brand2);

//        删除
        DeleteByBrandId(4);

    }

    public static void queryBrand() throws SQLException {
        BrandDao brandDao = new BrandDao();
        List<Brand> list = brandDao.selectBrand();
        System.out.println(list);
        Connection connection = DbUtils.getConnection();
    }

    public static void AddBrand(Brand b){

        BrandDao brandDao = new BrandDao();

        System.out.println(brandDao.insert(b));
    }

    public static void UpdateBrand(Brand b){
        BrandDao brandDao = new BrandDao();
        System.out.println(brandDao.update(b));
    }

    public static void DeleteByBrandId(Integer id){
        BrandDao brandDao = new BrandDao();
        System.out.println(brandDao.DeleteByBrandId(id));
    }



}
